SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
ark_root=$(dirname $(dirname $(dirname $(dirname $(dirname "$SCRIPT_DIR")))))
arkcompiler_tool_path=$(dirname "$ark_root")/arkcompiler_tool
static_core_path=$ark_root/arkcompiler/runtime_core/static_core
arkcompiler_out_path=$ark_root/out/x64.debug/arkcompiler

echo "arkcompiler_tool_path: $arkcompiler_tool_path"
echo "static_core_path: $static_core_path"
echo "arkcompiler_out_path: $arkcompiler_out_path"

rm -rf $arkcompiler_tool_path
mkdir $arkcompiler_tool_path
mkdir $arkcompiler_tool_path/clang_x64
mkdir -p $arkcompiler_tool_path/plugins/ets/stdlib

# compiler
cd $ark_root
./ark.py x64.debug static_core es2panda ark_link arkts_abc2prog arkts_disasm arkts_bin

# collect files
cp -r $static_core_path/plugins/ets/stdlib/escompat $arkcompiler_tool_path/plugins/ets/stdlib/escompat
cp -r $static_core_path/plugins/ets/stdlib/std $arkcompiler_tool_path/plugins/ets/stdlib/std

cp -p $arkcompiler_out_path/ets_frontend/es2panda $arkcompiler_tool_path/clang_x64/
cp -r $arkcompiler_out_path/runtime_core/* $arkcompiler_tool_path/clang_x64/
cp -r $arkcompiler_out_path/ets_runtime/*.so $arkcompiler_tool_path/clang_x64/
cp $ark_root/out/x64.debug/gen/arkcompiler/runtime_core/static_core/plugins/ets/etsstdlib.abc $arkcompiler_tool_path/plugins/ets/
cp -r $ark_root/out/x64.debug/thirdparty/libuv/*.so $arkcompiler_tool_path/clang_x64/
cp -r $ark_root/out/x64.debug/thirdparty/icu/*.so $arkcompiler_tool_path/clang_x64/
cp -r $ark_root/out/x64.debug/thirdparty/bounds_checking_function/*.so $arkcompiler_tool_path/clang_x64/
cp -r $ark_root/out/x64.debug/arkui/napi/*.so $arkcompiler_tool_path/clang_x64/